#define DLLEXPORT
#include "TE.h"
#include "../TECore/TextEngene.h"

#pragma warning(disable : 4800)

extern "C"
{
	MYDLLTYPE PTextEngene CreateTextEngene(int x, int y, int width, int height, DWORD style, UINT id, HWND hParent)
	{
		TextEngene* engene = new TextEngene();
		engene->Create(x, y, width, height, style, id, hParent);
		return (PTextEngene)engene;
	}

	MYDLLTYPE BOOL TE_IsModified(PTextEngene te)
	{
		return (BOOL)((TextEngene*)te)->IsModified();
	}

	MYDLLTYPE void TE_SetModified(PTextEngene te, BOOL modified)
	{
		((TextEngene*)te)->SetModified((bool)modified);
	}

	MYDLLTYPE void TE_GetText(PTextEngene te, wchar_t** str)
	{
		unsigned int size = ((TextEngene*)te)->GetText().size();
		(*str) = new wchar_t[size + 1];
		wcscpy_s(*str, size + 1, ((TextEngene*)te)->GetText().c_str());
	}

	MYDLLTYPE void TE_SetText(PTextEngene te, const wchar_t* str)
	{
		((TextEngene*)te)->SetText(str);
	}

	MYDLLTYPE BOOL TE_IsReadOnly(PTextEngene te)
	{
		return (BOOL)((TextEngene*)te)->IsReadOnly();
	}

	MYDLLTYPE void TE_SetReadOnly(PTextEngene te, BOOL ReadOnly)
	{
		((TextEngene*)te)->SetReadOnly((bool)ReadOnly);
	}

	MYDLLTYPE BOOL TE_IsSelection(PTextEngene te)
	{
		return (BOOL)((TextEngene*)te)->IsSelection();
	}

	MYDLLTYPE HWND TE_GetHwnd(PTextEngene te)
	{
		return ((TextEngene*)te)->hWnd;
	}

	MYDLLTYPE void DestructTextEngene(PTextEngene te)
	{
		delete te;
	}
}